<?php

declare (strict_types=1);
/**
 * @copyright 深圳市易果网络科技有限公司
 * @version 1.0.0
 * @link https://dayiguo.com
 */

namespace App\Controller\user;

use App\Dao\AdvertisingDao;
use App\Request\User\Advertising\IndexRequest;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;

/**
 * 广告控制器
 *
 * @AutoController()
 * @author 谢声强(861167322@qq.com)
 */
class AdvertisingController extends Controller
{
    /**
     * 广告DAO
     *
     * @Inject
     * @var AdvertisingDao
     */
    private $dao;

    /**
     * 广告获取接口
     *
     * @param IndexRequest $request
     * @return mixed
     */
    public function index(IndexRequest $request)
    {
        $params = $request->all();

        isset($params['type']) && $params['type'] = (int)$params['type'];

        // 查出广告
        $advertising_list = $this->dao->getAdvertisingByType($params['type']);

        $this->success($advertising_list);
    }
}
